import unittest
import requests


class MyTestCase(unittest.TestCase):
    def test_something(self):
        # data = {
        #     "mid": 9,
        #     "s": 4,
        #     "page": 1,
        #     "pagesize": 10,
        #     "cityId": 201
        # }
        # r = requests.get("https://selectcar.yiche.com/selectcarforapp", params=data)

        date1={"mid":9,"s":4,"page":1,"pagesize":20,"cityId":201}
        r=requests.get("https://selectcar.yiche.com/selectcarforapp?",params=date1)
        # 打印返回的json值
        print(r.json())
        # #打印url
        print(r.url)
        # #打印文本值
        print(type(r.text))
        # #打印格式
        print(r.encoding)
        # #返回的响应体
        #print(r.content)
        # #状态码
        print(r.status_code)
        # #获取头部信息
        print(r.headers)
        # 获取节点的值
        a=r.json()
        print(a['status'])
        print(a['data']['resList'][0]['carNum'])
        le = len(a['data']['resList'])
        print(le)
        for i in range(le):
            print(a['data']['resList'][i]['brandName'])

#         非空判断
        if le>0:
            print('非空')

        if r.status_code==200:
            print('连接成功')
        else:
            print('失败，代码{}'.format(r.status_code))

        assert r.status_code==200



if __name__ == '__main__':
    unittest.main()
